package com.example.testapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.example.testapplication.application.MyApp;

public class Activity_application extends AppCompatActivity {

    private static final String TAG = "Activity_application";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_application);
        setTitle("Activity_application");

        Log.d(TAG,"onCreate:" + getApplication()); // onCreate:android.app.Application@e44114a
    }

    @Override
    protected void onResume() {
        super.onResume();
        MyApp app = (MyApp) getApplication();

    }

    public void onClick(View view){
        switch (view.getId()) {
            case R.id.btnGotoActivity2:
                startActivity(new Intent(this, Main2Activity.class));
                break;
//            case R.id.btnStartService:
//                startService(new Intent(this, MyService.class));
//                break;
//            case R.id.btnSetUserName: {
//                MyApp app = (MyApp) getApplication();
//                app.setUserName("iMooc");
//                Toast.makeText(MainActivity.this, "Set user name to be " + app.getUserName(), Toast.LENGTH_SHORT).show();
//                break;
//            }
//            case R.id.btnGetUserName: {
//                MyApp app = (MyApp) getApplication();
//                Toast.makeText(MainActivity.this, app.getUserName(), Toast.LENGTH_SHORT).show();
//                break;
        }

    }
}